﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using AutoMapper;
using FwProject.ShoppingMall.Shop;

namespace FwProject.Shop.Dto
{
    [AutoMap(typeof(ShopProduct))]
    public class ShopProductInput
    {
        /// <summary>
        /// 商品分类id
        /// </summary>
        [Display(Name = "商品分类")]
        public Guid ShopTypeid { get; set; }

        /// <summary>
        /// 商品宣传图片
        /// </summary>
        [Display(Name = "商品宣传图片")]
        public string ImagePic { get; set; }
        /// <summary>
        /// 商品名称
        /// </summary>
        [Required]
        [Display(Name = "商品名称")]
        public string ProductName { get; set; }
        /// <summary>
        /// 商品编号
        /// </summary>
        [Required]
        [Display(Name = "商品编号")]
        public string ProductNumber { get; set; }
        /// <summary>
        /// 市场价格
        /// </summary>
        [Required]
        [Display(Name = "市场价格")]
        public decimal MarketPrice { get; set; } = 0m;
        /// <summary>
        /// 商品介绍
        /// </summary>
        [Required]
        [Display(Name = "详情描述")]
        public string ProductDetails { get; set; }
        /// <summary>
        /// 规格销售价
        /// </summary>
        [Required]
        [Display(Name = "销售价")]
        public decimal SpcemarketPrice { get; set; } = 0m;
        /// <summary>
        /// 规格成本价
        /// </summary>
        [Required]
        [Display(Name = "成本价")]
        public decimal SpcecostPrice { get; set; } = 0m;
        /// <summary>
        /// 重量
        /// </summary>
        [Required]
        [Display(Name = "重量")]
        public float SpceWeight { get; set; } = 0;
        /// <summary>
        /// 是否开启规格
        /// </summary>
        [Display(Name = "是否开启规格")]
        public bool SpceIsActive { get; set; } = false;
        /// <summary>
        /// 品牌id
        /// </summary>
        [Display(Name = "品牌编号")]
        public Guid? Brandid { get; set; }
        /// <summary>
        /// 单位
        /// </summary>
        [Display(Name = "计价单位")]
        public string Unit { get; set; }
        /// <summary>
        /// 是否上架
        /// </summary>
        [Display(Name = "是否上架")]
        public bool IsGrounding { get; set; } = true;
        /// <summary>
        /// 供应商id
        /// </summary>
        [Display(Name = "供应商编号")]
        public Guid ShopSupplierid { get; set; }
        /// <summary>
        /// 销售模式
        /// </summary>
        [Required]
        [Display(Name = "销售模式")]
        public ShopProductFlag ShopProductFlag { get; set; } = ShopProductFlag.正常;
    }

    [AutoMap(typeof(ShopProduct))]
    public class ShopProductEnterDto
    {
        #region 商品基础信息
        [Display(Name = "商品宣传图片")]
        public string ImagePic { get; set; }

        [Display(Name = "商品分类")]
        public Guid ShopTypeid { get; set; }

        [Required]
        [Display(Name = "商品名称")]
        public string ProductName { get; set; }

        [Required]
        [Display(Name = "商品编号")]
        public string ProductNumber { get; set; }

        [Required]
        [Display(Name = "市场价格")]
        public decimal MarketPrice { get; set; } = 0m;

        [Display(Name = "计价单位")]
        public string Unit { get; set; }

        [Display(Name = "详情描述")]
        public string ProductDetails { get; set; }

        [Required]
        [Display(Name = "销售价")]
        public decimal SpcemarketPrice { get; set; } = 0m;

        [Required]
        [Display(Name = "成本价")]
        public decimal SpcecostPrice { get; set; } = 0m;

        [Display(Name = "是否上架")]
        public bool IsGrounding { get; set; }

        [Required]
        [Display(Name = "重量")]
        public float SpceWeight { get; set; } = 0;

        [Display(Name = "是否开启规格")]
        public bool SpceIsActive { get; set; }


        public ShopProductFlag ShopProductFlag { get; set; } = ShopProductFlag.正常;

        /// <summary>
        /// 供应商
        /// </summary>
        public Guid ShopSupplierid { get; set; }
        #endregion

        /// <summary>
        /// 宣传图
        /// </summary>
        [IgnoreMap]
        public List<string> PropagandaImgs { get; set; }

        /// <summary>
        /// 详情图
        /// </summary>
        [IgnoreMap]
        public List<string> DetailsImgs { get; set; }

        #region 规格
        /// <summary>
        /// 规格
        /// </summary>
        [IgnoreMap]
        public List<SpecDto> Specs { get; set; }

        #endregion

        /// <summary>
        /// 品牌Id
        /// </summary>
        [IgnoreMap]
        public Guid? ShopBrandId { get; set; }

        /// <summary>
        /// 属性
        /// </summary>
        [IgnoreMap]
        public List<AttrDto> Attrs { get; set; }

        /// <summary>
        /// 参数组
        /// </summary>
        [IgnoreMap]
        public List<ParsGroupDto> ParsGroups { get; set; }

        /// <summary>
        /// 标签Id
        /// </summary>
        [IgnoreMap]
        public string Tags { get; set; }
    }

    public class ParsGroupDto
    {
        public Guid? Id { get; set; }

        public List<ParsValueDto> ParsValues { get; set; }
    }
    public class ParsValueDto
    {
        public Guid? ValueId { get; set; }
        public string ParsKey { get; set; }
        public string ParsValue { get; set; }
    }
    public class SpecDto
    {
        /// <summary>
        /// SKUId
        /// </summary>
        public Guid? Id { get; set; }
        /// <summary>
        /// 规格Id
        /// </summary>
        public string Specids { get; set; }
        /// <summary>
        /// 规格值Id
        /// </summary>
        public string Specvids { get; set; }

        /// <summary>
        /// 规格值名称
        /// </summary>
        public string SpecvNames { get; set; }

        /// <summary>
        /// 销售价
        /// </summary>
        public decimal Price { get; set; }

        /// <summary>
        /// 重量
        /// </summary>
        public float Weight { get; set; }

        /// <summary>
        /// 成本价
        /// </summary>
        public decimal Cost { get; set; }

    }
    public class AttrDto
    {
        public Guid? Id { get; set; }

        public string Attrkey { get; set; }

        public string Attrvalue { get; set; }
    }
}
